<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>档案移交</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>移交信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">档案编号</label>
                        <div class="layui-input-block">
                            <input type="text" id="number" placeholder="请输入" autocomplete="off" disabled class="layui-input disabled">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">档案名称</label>
                        <div class="layui-input-block">
                            <input type="text" id="name" placeholder="请输入" autocomplete="off" disabled class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>档案类型</label>
                        <div class="layui-input-block">
                            <select id="danglei" name="danglei" lay-filter="danglei">
                                <option value="原件">原件</option>
                                <option value="复印件">复印件</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>移交人</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=yier&type=user&single=1', '770px', '490px');"></div>
                                <div class="tanxiannei" id="yier"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=yier&type=user&single=1', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="yier_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>移交日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="yidt" id="yidt" placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>移交份数</label>
                        <div class="layui-input-block">
                            <input type="number" name="yinum" id="yinum" placeholder="请输入" clearable autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>移交至</label>
                        <div class="layui-input-block">
                            <select id="jiaohou" name="jiaohou" lay-filter="jiaohou">
                                <option value="1">工程档案库</option>
                                <option value="3">行政档案库</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label"><text>*</text>通知人</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=jieer&type=user&single=1', '770px', '490px');"></div>
                                <div class="tanxiannei" id="jieer"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=jieer&type=user&single=1', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                            <div id="jieer_tanerror" class="tanerrormsg"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">移交说明</label>
                        <div class="layui-input-block">
                            <textarea id="jieshuo" name="jieshuo" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;

    $("#commentForm").validate({
        rules: {
            yidt: {required: true},
            yinum: {required: true},
        },
        messages:{
            yidt: {required: "请选择"},
            yinum: {required: "请输入"},
        }
    });

    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_coss_jiao,data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;

                $("#number").val(data.number);
                $("#name").val(data.name);
                $("#danglei").val(data.danglei);
                $("#yidt").val(data.yidt);

                if(data.yier_info.length > 0){
                    tan_tags_init('#yier', data.yier_info);
                }
                render_from();
            }
        });

        form.on('submit(add)', function(data){

            data.field.yier = tan_tags_getvalue("#yier", 'user');
            data.field.jieer = tan_tags_getvalue("#jieer", 'user');
            var validRes = $("#commentForm").valid();

            if(!data.field.yier){
                $("#yier").parents('.tanxian').addClass('tanerror');
                $('#yier_tanerror').text('请选择');
                validRes = false;
            }else{
                $("#yier").parents('.tanxian').removeClass('tanerror');
                $('#yier_tanerror').text('');
            }

            if(!data.field.jieer){
                $("#jieer").parents('.tanxian').addClass('tanerror');
                $('#jieer_tanerror').text('请选择');
                validRes = false;
            }else{
                $("#jieer").parents('.tanxian').removeClass('tanerror');
                $('#jieer_tanerror').text('');
            }

            if(!validRes){return false;}


            data = parseMoney(data);
            data.field.yiid = param_id;
            facade.ajax({url: ask_coss_jiao, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });

</script>
</body>
</html>
